
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Label;
import java.awt.Panel;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.*;

import javax.swing.Box;
import javax.swing.JApplet;


import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JSpinner;

import javax.swing.SwingUtilities;
import javax.swing.text.JTextComponent;

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.ImageObserver;

import javax.swing.*;

import java.net.*;
import java.io.*;

public class SatApplet extends JApplet implements Runnable {

    int[] arr;
    int[] ExportObject;
    int TotalScore=0;
    int exval=0;
    URL url=null;
    int jh=0;
    int xx=0;
    int xxx=0;
    int ans=0;
    int d = 0;
    double money=0;
    int turn = 0;
    int chance = 1;
    int numWhite = 0;
    double rot=1;
    int dx ; 
    int dy ;
    int stf = 1, stop=1;
    int a1=3, a2=7, a3=10;
    Image img,ar;
    int ang=0;
      
    Image image;
    
    int w=200,h=200;
    int count = 0;
    Thread runner=null;
    
    Dimension appletSize;
    int appletHeight,appletWidth;
    
    Label totalEarningsLabel, turnsLeftLabel, eneLabel, momLabel, vradLabel, vthetaLabel, vradnewLabel, vthetanewLabel;
    Label enenewLabel, momnewLabel;
    TextField totalEarningsText, turnsLeftText, eneText, momText, vradText, vthetaText, vradnewText, vthetanewText, enenewText, momnewText;
    JSeparator separator;
    Button StartButton, PauseButton;
    private boolean test;

    private Button ResetButton;
    
    Box button_bar;
    Button InstrButton;
    JTextComponent fr, fr1,fr2, fr3, fr4,frame, _imaginary,_instructions;

    Image backbuffer;
    Graphics backg;
    
    public void init(){
    	 backbuffer = createImage( w, h );
         backg = backbuffer.getGraphics();
         backg.setColor( Color.black );
         backg.fillRect( 0, 0, w, h );
         backg.setColor( Color.white );
        arr = new int[11];
        ExportObject = new int[11];
        try{
        url=new URL("http://localhost/SatApplet/test.php");
        }catch(MalformedURLException me){}
        
        img = getImage(getDocumentBase(), "ash1.jpg");
        ar = getImage(getDocumentBase(), "as.jpg");
        JLabel label = new JLabel("We respect the privacy needs of people who respond to this\nsurvey game. The information that you provide will be \nreported in aggregate with those of other respondents and \nused for research purpose only. Please contact \ngnqsurvey@gmail.com if you have any questions concerning the collection \nand use of information.");
        label.setFont(new Font("serif", Font.PLAIN, 14));
JOptionPane.showMessageDialog(_instructions,"We respect the privacy needs of people who respond to this\nsurvey game. The information that you provide will be \nreported in aggregate with those of other respondents and \nused for research purpose only. Please contact gnqsurvey@gmail.com\nif you have any questions concerning the collection \nand use of information.","Undertaking",JOptionPane.INFORMATION_MESSAGE);
       //createForm();
		test=true;
        makeUI();
        test=true;
        //SaveData();
    }
    
    
    
    public void makeUI() {
        
        appletHeight = getHeight();
        appletWidth = getWidth();
        
        Color  panelbg=Color.BLACK;
        Color  panelfg=Color.white;
        Color  buttonfg=Color.black;
        
        Panel pa = new Panel();
        add("North",pa);
        
        pa.setBackground(Color.WHITE);
        
        Label appletLabel = new Label("Stop The Disc");
        appletLabel.setForeground(Color.BLACK);
        appletLabel.setFont(new Font("Times New Roman", Font.BOLD, 30));
        
        pa.add(appletLabel);
        
               
        totalEarningsLabel = new Label("Total Earnings:", Label.LEFT);
        turnsLeftLabel = new Label("Number of Reds:", Label.LEFT);
        
        totalEarningsText = new TextField(String.valueOf(money));
        turnsLeftText = new TextField(String.valueOf(numWhite));
        totalEarningsText.setEditable(false);
        turnsLeftText.setEditable(false);
       
        StartButton = new Button("Start");
        PauseButton = new Button("Stop");
        ResetButton = new Button("Reset");
        InstrButton = new Button("Instructions");
                
        
        Panel p1 = new Panel(new GridLayout(2, 1));
        Panel p2 = new Panel(new GridLayout(2, 1));
        Panel p5 = new Panel(new GridLayout(1, 3));

        Panel p10 = new Panel(new GridLayout(1, 1));
    
        p1.add(totalEarningsLabel);
        p1.add(turnsLeftLabel);
        p2.add(totalEarningsText);
        p2.add(turnsLeftText);
    

        //p5.add(ResetButton);
        p5.add(StartButton);
        p5.add(PauseButton);
        
    
        p10.add(InstrButton);
        
        Dimension tempDim=new Dimension(appletWidth/25, appletHeight/12);
    
        Panel button_bar =new Panel();
        button_bar.setBackground(Color.WHITE);
        //rest.setBackground(Color.BLACK);
        
        tempDim.setSize(1*appletWidth/20, appletHeight/12);
                  
        button_bar.add(p1);
        tempDim.setSize(appletWidth/100, appletHeight/100);

        button_bar.add(p2);
        button_bar.add(Box.createRigidArea(tempDim));
        
        button_bar.add(Box.createRigidArea(tempDim));
        button_bar.add(p5, Component.CENTER_ALIGNMENT);
        button_bar.add(Box.createRigidArea(tempDim));
        
        button_bar.add(Box.createRigidArea(tempDim));
    
        button_bar.add(Box.createRigidArea(tempDim));
        button_bar.add(p10, Component.CENTER_ALIGNMENT);
        
        button_bar.validate();
        add("South",button_bar);
        button_bar.validate();
        getContentPane().setVisible(true);
        
        StartButton.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent arg0) {
                       
            	test=true; 
                if(stf==1)
                {
                /*    ang=270;
                    repaint();*/
                    d=1;
                stop=1;
                stf=0;
                createnewthread();
                }
                else
                {
                    JOptionPane.showMessageDialog(fr4,
                            "The disc is already rotating!!!",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                }
                
            }
        });
        
        PauseButton.addActionListener(new ActionListener()
        {    
            
            @Override
            public void actionPerformed(ActionEvent arg0)
            {
            	test=true;
                if(stop==1)
                    
                {
                    jh=1;
                    
                    //repaint();
                    
                        /*ang = ang + 36;
                        System.out.println(ang/36);
                        repaint();
                    }*/
                    d=0;
                    stf=1;
                    stop=0;
                    if(chance<=2)
                    {
                        turn=turn+1;
                        if(turn!=a1&&turn!=a2&&turn!=a3)
                        {
                            if((ang/36)%2==0)
                            {
                                    xxx = 1;
                                //ang = ang + (ang%36)+10;
                                    ang=ang+36;
                                    if(ang%36<10)
                                        ang=ang+10;
                                    if(ang%36>26)
                                        ang=ang-10;
                                    //repaint();
                                //System.out.println("Red---");
                                //repaint();
                            }
                            else
                            {
                                
                            //    System.out.println("Green++++");
                            }
                                
                            money=money+1000;
                            totalEarningsText.setText(String.valueOf(money));
                        }
                        else 
                        {
                            if((ang/36)%2==0)
                            {
                                //ang = ang + (ang%36)+10;
                                //System.out.println("Red+++++");
                                //repaint();
                            }
                            else
                            {
                                xxx=1;
                                ang=ang+36;
                                if(ang%36<10)
                                    ang=ang+10;
                                if(ang%36>26)
                                    ang=ang-10;
                                //repaint();
                                //System.out.println("Green----");
                            }
                            
                            numWhite++;
                            turnsLeftText.setText(String.valueOf(numWhite));
                        }
                        if(numWhite==3)
                        {
                            Object[] possibilities = {"1", "2", "3", "4", "5","6", "7",  "8", "9", "10"};
                            String s = (String)JOptionPane.showInputDialog(
                                                fr,
                                                "To what extent were you able to master the game and get the desired outcome?",
                                                "Rate",
                                                JOptionPane.PLAIN_MESSAGE,
                                                null,
                                                possibilities,
                                                "1");
                            int d=Integer.parseInt(s);
                            ExportObject[exval]=d;
                            exval++;
                            //Syste`m.out.println("************************"+s);
                            Object[]     options = {"Rotate",
                            "Don't Rotate"};
            int n = JOptionPane.showOptionDialog(frame,
            "Rotate the disc once more and if you win, you will get Rs. "+ money + " more. (if you lose: u gain 0 Rs.) or Don�t rotate and take Rs. "+money/2+" more.", 
            "You have won Rs. "+money,
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,     //do not use a custom Icon
            options,  //the titles of buttons
            options[0]); //default button title
             Object[] options1 = {"Rotate",
            "Don't Rotate"};
           //  System.out.println(n);
             ExportObject[exval]=n;
             exval++;
int n1 = JOptionPane.showOptionDialog(fr1,
"Rotate the disc once more and if you lose, you will have to give Rs. "+ money +  "(if you win: you lose Rs.0) or Don�t play the game and give Rs. "+ money/2,
"Suppose you have won Rs. "+2*money,
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,     //do not use a custom Icon
options1,  //the titles of buttons
options1[0]); //default button title
//System.out.println(n1);
System.out.print(chance);
ExportObject[exval]=n1;
exval++;
                    if(exval==9)
                        SaveData();
                            chance++;
                            numWhite=0;
                            money=0;
                            turn=0;
                            a1=1;
                            a2=3;
                            a3=5;
                            totalEarningsText.setText(String.valueOf(money));
                            turnsLeftText.setText(String.valueOf(numWhite));
                            if(chance==3)
                            {
                                JOptionPane.showMessageDialog(fr2,
                                        "We need only 2 tries, thanks!!!",
                                        "Thank You!!!",
                                        JOptionPane.PLAIN_MESSAGE);
                                SaveData();

                                try{
                                    HttpURLConnection connection=(HttpURLConnection)url.openConnection() ;
                                    connection.setRequestMethod("POST");
                                    connection.setDoOutput(true);
                                    PrintWriter out = new PrintWriter(connection.getOutputStream());
                                    out.println("Name=Mudit");
                                    out.close();
                                    

                                    }catch(IOException ie){}
                          }
                        }
                    }
                    else
                    {
                        
                        
                    }
                    
                    
                    runner.stop();
                }
                else
                {
                    JOptionPane.showMessageDialog(fr3,
                            "First start rotating the disc!!!",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                
                }
                
            
            }
        });    
            
        ResetButton.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub
                runner.stop();
                
                money=0;
                numWhite = 0;
                chance=0;
                totalEarningsText.setText(String.valueOf(money));
                turnsLeftText.setText(String.valueOf(numWhite));
                
            
                createnewthread();
                    
                //system.out.println("after");
            }
        });
        
        InstrButton.addActionListener(new ActionListener()
        {    
            @Override
            public void actionPerformed(ActionEvent arg0)
            {
                    JOptionPane.showMessageDialog(_instructions,"Objective: To win maximum amount of money.\nFor every Green colour in-front of the stick Rs. 1000 will be credited in your account.\nIf the disc is stopped infront of Green it will stop at Green.\nGame will stop when red colour appears for the 3rd time\nPress start to rotate the disc\nPress stop to stop the disc ","Instructions",JOptionPane.INFORMATION_MESSAGE);
            }
        });
    }
    
    public void SaveData()
    {
        
        for(int i=0;i<10;i++)
            System.out.println(ExportObject[i]);
        
        try{
            
            FileWriter fstream = new FileWriter("nursing.csv",true);
              BufferedWriter out = new BufferedWriter(fstream);
              out.write('\n');
              for(int i=0;i<10;i++)
              {
                 out.write(Integer.toString(ExportObject[i]));
                  if(i<9)
                  {
                      out.write(',');  
                  }
              }
              
              //Close the output stream
              out.close();
            
              }catch (Exception e){//Catch exception if any
              System.err.println("Error: " + e.getMessage());
              }
              }

    public void paint( Graphics g ) {
    	update(g);
        
     }
    
    int getLoc()
    {
        return (ang);
    }
    public void update(Graphics g){
         int x = (getWidth() - img.getWidth(this))/2;
         int y = (getHeight() - img.getHeight(this))/2;        
               //int h1,w1;
        
      /*  if(test)
        {
        	h1 = appletSize.height;
            w1 = appletSize.width;
        */    
      //	Graphics2D g3 = (Graphics2D) g;
       //     g3.setColor(Color.BLACK);
        //    g3.fillRect(0, 0, w, h);
            
            //test=false;
            
        //}
         //   ImageObserver ar_o = (ImageObserver) ar;
         //   ImageObserver img_o = (ImageObserver) img;
        Graphics2D g3d = (Graphics2D)g;
       g3d.drawImage(ar,x+85, y-135,this);   
        if(d==1)
        {
            
                ang = ang+10;
            
                
            if(ang>=360)
                ang=0;
            
        }
         Graphics2D g2d = (Graphics2D)g;
         AffineTransform origXform = g2d.getTransform();
         AffineTransform newXform = (AffineTransform)(origXform.clone());
         
         int xRot = this.getWidth()/2;
         int yRot = this.getHeight()/2;
         newXform.rotate(Math.toRadians(ang), xRot, yRot);
         g2d.setTransform(newXform);
         
        g2d.drawImage(img, x, y, this);
         g2d.setTransform(origXform);
         if(xx==1)
         {
             xx=0;
            // System.out.println(xx);

         }
         //g.drawImage( backbuffer, 0, 0, this );
         //super.paintComponents(g);
         
         
    } 
        
public void createForm()

{
        int vl=0;
        String cmb;
        Object[] items1 = {"","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60"};
        Object[] items2 = {"","Male","Female"};
        Object[] items3 = {"","Less than 300","300-500","500-700","700-1000","1000-2000","2000-3000","3000-4000","4000-5000","5000-6000","More than 6000"};
        
       Object[] items = {"","Strongly Agree", "Agree", "Disagree", "Strongly Disagree"};
       JComboBox combo11 = new JComboBox(items1);
       JComboBox combo12 = new JComboBox(items2);
       JComboBox combo13 = new JComboBox(items3);
        JComboBox combo1 = new JComboBox(items);
        JComboBox combo2 = new JComboBox(items);
        JComboBox combo3 = new JComboBox(items);
        JComboBox combo4 = new JComboBox(items);
        JComboBox combo5 = new JComboBox(items);
        JComboBox combo6 = new JComboBox(items);
        JComboBox combo7 = new JComboBox(items);
        JComboBox combo8 = new JComboBox(items);
        JComboBox combo9 = new JComboBox(items);
        JComboBox combo10 = new JComboBox(items);
        JPanel panel = new JPanel(new GridLayout(0, 1));
        panel.add(new JLabel("Age"));
        panel.add(combo11);
        panel.add(new JLabel("Gender"));
        panel.add(combo12); 
        panel.add(new JLabel("Monthly Expenditure (in Rs.)"));
        panel.add(combo13);
        panel.add(new JLabel("I feel that I'm a person of worth, at least on an equal plane with others."));
        panel.add(combo1);
        panel.add(new JLabel("I feel that I have a number of good qualities."));
        panel.add(combo2);
        panel.add(new JLabel("All in all, I am inclined to feel that I am a failure."));
        panel.add(combo3);
        panel.add(new JLabel("I am able to do things as well as most other people."));
        panel.add(combo4);
        panel.add(new JLabel("I feel I do not have much to be proud of."));
        panel.add(combo5);
        panel.add(new JLabel("I take a positive attitude toward myself."));
        panel.add(combo6);
        panel.add(new JLabel("On the whole, I am satisfied with myself."));
        panel.add(combo7);
        panel.add(new JLabel("I wish I could have more respect for myself."));
        panel.add(combo8);
        panel.add(new JLabel("I certainly feel useless at times."));
        panel.add(combo9);
        panel.add(new JLabel("At times I think I am no good at all."));
        panel.add(combo10);
        Object[] options = {"Play"};
        int result = JOptionPane.showOptionDialog(null, panel, "Survey",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,null,options,options[0]);
       if (result == JOptionPane.OK_OPTION) {
            if(combo13.getSelectedItem().equals("")||combo12.getSelectedItem().equals("")||combo11.getSelectedItem().equals("")||combo1.getSelectedItem().equals("")||combo2.getSelectedItem().equals("")||combo3.getSelectedItem().equals("")||combo4.getSelectedItem().equals("")||combo5.getSelectedItem().equals("")||combo6.getSelectedItem().equals("")||combo7.getSelectedItem().equals("")||combo8.getSelectedItem().equals("")||combo9.getSelectedItem().equals("")||combo10.getSelectedItem().equals(""))
            {
                JOptionPane.showMessageDialog(null,
                        "Please Fill All Fields",
                        "Error",
                        JOptionPane.ERROR_MESSAGE);
                createForm();
            }
              else 
              {
                if(combo3.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[3]=0;
                  }
                  if(combo3.getSelectedItem().equals("Agree"))
                  {
                      arr[3]=1;
                  }
                  if(combo3.getSelectedItem().equals("Disagree"))
                  {
                      arr[3]=2;
                  }
                  if(combo3.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[3]=3;
                  }
                  
                if(combo5.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[5]=0;
                  }
                  if(combo5.getSelectedItem().equals("Agree"))
                  {
                      arr[5]=1;
                  }
                  if(combo5.getSelectedItem().equals("Disagree"))
                  {
                      arr[5]=2;
                  }
                  if(combo5.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[5]=3;
                  }
                  
                if(combo8.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[8]=0;
                  }
                  if(combo8.getSelectedItem().equals("Agree"))
                  {
                      arr[8]=1;
                  }
                  if(combo8.getSelectedItem().equals("Disagree"))
                  {
                      arr[8]=2;
                  }
                  if(combo8.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[8]=3;
                  }
                if(combo9.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[9]=0;
                  }
                  if(combo9.getSelectedItem().equals("Agree"))
                  {
                      arr[9]=1;
                  }
                  if(combo9.getSelectedItem().equals("Disagree"))
                  {
                      arr[9]=2;
                  }
                  if(combo9.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[9]=3;
                  }
                if(combo10.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[10]=0;
                  }
                  if(combo10.getSelectedItem().equals("Agree"))
                  {
                      arr[10]=1;
                  }
                  if(combo10.getSelectedItem().equals("Disagree"))
                  {
                      arr[10]=2;
                  }
                  if(combo10.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[10]=3;
                  }
                  
                  
                if(combo7.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[7]=3;
                  }
                  if(combo7.getSelectedItem().equals("Agree"))
                  {
                      arr[7]=2;
                  }
                  if(combo7.getSelectedItem().equals("Disagree"))
                  {
                      arr[7]=1;
                  }
                  if(combo7.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[7]=0;
                  }
                  
                if(combo6.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[6]=3;
                  }
                  if(combo6.getSelectedItem().equals("Agree"))
                  {
                      arr[6]=2;
                  }
                  if(combo6.getSelectedItem().equals("Disagree"))
                  {
                      arr[6]=1;
                  }
                  if(combo6.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[6]=0;
                  }
                  
                if(combo4.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[4]=3;
                  }
                  if(combo4.getSelectedItem().equals("Agree"))
                  {
                      arr[4]=2;
                  }
                  if(combo4.getSelectedItem().equals("Disagree"))
                  {
                      arr[4]=1;
                  }
                  if(combo4.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[4]=0;
                  }
                  
                if(combo2.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[2]=3;
                  }
                  if(combo2.getSelectedItem().equals("Agree"))
                  {
                      arr[2]=2;
                  }
                  if(combo2.getSelectedItem().equals("Disagree"))
                  {
                      arr[2]=1;
                  }
                  if(combo2.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[2]=0;
                  }
                  
                if(combo1.getSelectedItem().equals("Strongly Agree"))
                  {
                      arr[1]=3;
                  }
                  if(combo1.getSelectedItem().equals("Agree"))
                  {
                      arr[1]=2;
                  }
                  if(combo1.getSelectedItem().equals("Disagree"))
                  {
                      arr[1]=1;
                  }
                  if(combo1.getSelectedItem().equals("Strongly Disagree"))
                  {
                      arr[1]=0;
                  }
                  
                  
                 
                  int aa=0,bb=0,cc=0;
                if(combo11.getSelectedItem().equals("7"))
                  {
                      aa=7;
                  }
              if(combo11.getSelectedItem().equals("8"))
              {
                  aa=8;
              }
              if(combo11.getSelectedItem().equals("9"))
              {
                  aa=9;
              }
              if(combo11.getSelectedItem().equals("10"))
              {
                  aa=10;
              }
              if(combo11.getSelectedItem().equals("11"))
              {
                  aa=11;
              }
              if(combo11.getSelectedItem().equals("12"))
              {
                  aa=12;
              }
              if(combo11.getSelectedItem().equals("13"))
              {
                  aa=13;
              }
              if(combo11.getSelectedItem().equals("14"))
              {
                  aa=14;
              }
              if(combo11.getSelectedItem().equals("15"))
              {
                  aa=15;
              }
              if(combo11.getSelectedItem().equals("16"))
              {
                  aa=16;
              }
                  if(combo11.getSelectedItem().equals("17"))
                  {
                      aa=17;
                      System.out.println(aa);
                  }
                if(combo11.getSelectedItem().equals("18"))
                  {
                      aa=18;
                  }
               if(combo11.getSelectedItem().equals("19"))
                  {
                      aa=19;
                  }
               if(combo11.getSelectedItem().equals("20"))
                  {
                      aa=20;
                  }
               if(combo11.getSelectedItem().equals("21"))
                  {
                      aa=21;
                  }
               if(combo11.getSelectedItem().equals("22"))
                  {
                      aa=22;
                  }
             if(combo11.getSelectedItem().equals("23"))
                  {
                      aa=23;
                  }
             if(combo11.getSelectedItem().equals("24"))
                  {
                      aa=24;
                  }
             if(combo11.getSelectedItem().equals("25"))
                  {
                      aa=25;
                  }
             if(combo11.getSelectedItem().equals("26"))
                  {
                      aa=26;
                  }
             
             if(combo11.getSelectedItem().equals("27"))
             {
                 aa=27;
             }
             if(combo11.getSelectedItem().equals("28"))
             {
                 aa=28;
             }
             if(combo11.getSelectedItem().equals("29"))
             {
                 aa=29;
             }
             if(combo11.getSelectedItem().equals("30"))
             {
                 aa=30;
             }
             if(combo11.getSelectedItem().equals("31"))
             {
                 aa=31;
             }
             if(combo11.getSelectedItem().equals("32"))
             {
                 aa=32;
             }
             if(combo11.getSelectedItem().equals("33"))
             {
                 aa=33;
             }
             if(combo11.getSelectedItem().equals("34"))
             {
                 aa=34;
             }
             if(combo11.getSelectedItem().equals("35"))
             {
                 aa=35;
             }
             if(combo11.getSelectedItem().equals("36"))
             {
                 aa=36;
             }
             if(combo11.getSelectedItem().equals("37"))
             {
                 aa=37;
             }
             if(combo11.getSelectedItem().equals("38"))
             {
                 aa=38;
             }
             if(combo11.getSelectedItem().equals("39"))
             {
                 aa=39;
             }
             if(combo11.getSelectedItem().equals("40"))
             {
                 aa=40;
             }
             if(combo11.getSelectedItem().equals("41"))
             {
                 aa=41;
             }
             if(combo11.getSelectedItem().equals("42"))
             {
                 aa=42;
             }
             if(combo11.getSelectedItem().equals("43"))
             {
                 aa=43;
             }
             if(combo11.getSelectedItem().equals("44"))
             {
                 aa=44;
             }
             if(combo11.getSelectedItem().equals("45"))
             {
                 aa=45;
             }
             if(combo11.getSelectedItem().equals("46"))
             {
                 aa=46;
             }
             if(combo11.getSelectedItem().equals("47"))
             {
                 aa=47;
             }
             if(combo11.getSelectedItem().equals("48"))
             {
                 aa=48;
             }
             if(combo11.getSelectedItem().equals("49"))
             {
                 aa=49;
             }
             if(combo11.getSelectedItem().equals("50"))
             {
                 aa=50;
             }
             if(combo11.getSelectedItem().equals("51"))
             {
                 aa=51;
             }
             if(combo11.getSelectedItem().equals("52"))
             {
                 aa=52;
             }
             if(combo11.getSelectedItem().equals("53"))
             {
                 aa=53;
             }
             if(combo11.getSelectedItem().equals("54"))
             {
                 aa=54;
             }
             if(combo11.getSelectedItem().equals("55"))
             {
                 aa=55;
             }
             if(combo11.getSelectedItem().equals("56"))
             {
                 aa=56;
             }
             if(combo11.getSelectedItem().equals("57"))
             {
                 aa=57;
             }
             if(combo11.getSelectedItem().equals("58"))
             {
                 aa=58;
             }
             if(combo11.getSelectedItem().equals("59"))
             {
                 aa=59;
             }
             if(combo11.getSelectedItem().equals("60"))
             {
                 aa=60;
             }
             
             if(combo12.getSelectedItem().equals("Male"))
                  {
                      bb=1;
                  }     if(combo12.getSelectedItem().equals("Female"))
                  {
                      bb=2;
                  }
                if(combo13.getSelectedItem().equals("Less than 300"))
                  {
                      cc=10;
                  }
              if(combo13.getSelectedItem().equals("300-500"))
              {
                  cc=11;
              }
              if(combo13.getSelectedItem().equals("500-700"))
              {
                  cc=12;
              }
              if(combo13.getSelectedItem().equals("700-1000"))
              {
                  cc=13;
              }
               /* if(combo13.getSelectedItem().equals("Less than 1000"))
                  {
                      cc=1;
                  }*/
               if(combo13.getSelectedItem().equals("1000-2000"))
                  {
                      cc=2;
                  }
              if(combo13.getSelectedItem().equals("2000-3000"))
              {
                  cc=3;
              }
              if(combo13.getSelectedItem().equals("3000-4000"))
              {
                  cc=4;
              }if(combo13.getSelectedItem().equals("4000-5000"))
              {
                  cc=5;
              }if(combo13.getSelectedItem().equals("5000-6000"))
              {
                  cc=6;
              }if(combo13.getSelectedItem().equals("More than 6000"))
              {
                  cc=7;
              }
                            
                   for(int i=1;i<=10;i++) 
                       TotalScore = TotalScore + arr[i];
                 //  System.out.println("*********************"+TotalScore);
                 
                   ExportObject[exval]=TotalScore;
                 exval++;
                   ExportObject[exval]=aa;
                 exval++;
                   ExportObject[exval]=bb;
                 exval++;
                   ExportObject[exval]=cc;
                    
                   exval++;
                  
                makeUI();  
                test=true;
             }
            }
    }

    
    
    
    @Override
    public void run() {
        
        while(runner!=null){
            
            try {
            Thread.sleep(10);
            } catch (InterruptedException e) {
            
                e.printStackTrace();
            }
            
            appletSize = this.getSize();
            int h1 = this.getHeight();
            int w1 = this.getWidth();
            
            
            if(h != h1|| w != w1)
            {
                
                h = h1;
                w = w1;
                test=true;
                
            }
            
            repaint();
        }
        
        
    }
    
    public void start()
    {
        
        runner = new Thread(this);
        runner.start();
        
    }
    
    public void stop() {

         if ( runner != null && runner.isAlive() )
             runner.stop();
        runner = null;
    }
    
    protected void createnewthread() {
        
        runner = new Thread(this);
        runner.start();
    }
  
}


